package com.zc.gateway.security.service;

import com.zc.commons.auth.dto.LoginUserDetails;
import com.zc.gateway.infra.service.LoginUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
public class AuthenticationUserService implements ReactiveUserDetailsService {

    @Autowired
    private LoginUserDetailsService loginUserDetailsService;

    @Override
    public Mono<UserDetails> findByUsername(String userAccount) {

        // 根据账号查询用户
        LoginUserDetails userDetails = loginUserDetailsService.queryUserDetailsByAccount(userAccount);
        return Mono.justOrEmpty(userDetails);
    }
}
